
package com.ruoyi.web.controller.lingshui.completion;


import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.supervise.domain.BaseCompletionRecordCertInfo;
import com.ruoyi.supervise.domain.BaseConsturctionCertInfo;
import com.ruoyi.supervise.domain.CompletionRecordInfoTable;
import com.ruoyi.supervise.service.IBaseCompletionRecordCertInfoService;
import com.ruoyi.supervise.service.ICompletionRecordInfoTableService;
import com.ruoyi.system.domain.SysUser;

/**
 * @ClassName: CompletionReviewRecordController
 * @Description: 竣工备案审查记录的controller
 * @Author wtj
 * @DateTime 2020年4月15日 下午2:42:21
 */
@Controller
@RequestMapping("/completion/reviewRecord")
public class CompletionReviewRecordController extends BaseController{

	private String prefix = "lingshui/completion/reviewRecord";
	
	@Autowired
    private ICompletionRecordInfoTableService completionRecordInfoTableService;
	
	@Autowired
	private IBaseCompletionRecordCertInfoService baseCompletionRecordCertInfoService;
	
	/**
	 * @Title: reviewRecord
	 * @Description: 跳转到审查记录页面
	 * @Author wtj
	 * @DateTime 2020-9-25 17:03:17
	 * @return
	 */
	@RequiresPermissions("completion:reviewRecord:view")
	@GetMapping()
	public String reviewRecord()
	{
	    return prefix + "/reviewRecord";
	}
	
	/**
	 * @Title: list
	 * @Description: 获取审查记录页面列表数据
	 * @Author wtj
	 * @DateTime 2020-9-25 17:04:01
	 * @param completionRecordInfoTable
	 * @return
	 */
    @RequiresPermissions("completion:reviewRecord:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CompletionRecordInfoTable completionRecordInfoTable)
    {
        startPage();
        // 获取当前的用户信息
        SysUser currentUser = ShiroUtils.getSysUser();
        if(!currentUser.getLoginName().equals("admin") && !currentUser.getLoginName().trim().equals("lingshui")) {
        	completionRecordInfoTable.setInChargeDepartmentGuid(currentUser.getDept().getGuid());
        }
        List<CompletionRecordInfoTable> critList = completionRecordInfoTableService.selectCompletionRecordInfoTable(completionRecordInfoTable);
        return getDataTable(critList);
    }
    
    /**
     * @Title: export
     * @Description: 审查记录导出
     * @Author X1 Yoga
     * @DateTime 2020-9-25 17:11:48
     * @param completionRecordInfoTable
     * @return
     */
    @RequiresPermissions("completion:reviewRecord:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CompletionRecordInfoTable completionRecordInfoTable)
    {
    	List<CompletionRecordInfoTable> critList = completionRecordInfoTableService.selectCompletionRecordInfoTable(completionRecordInfoTable);
        ExcelUtil<CompletionRecordInfoTable> util = new ExcelUtil<CompletionRecordInfoTable>(CompletionRecordInfoTable.class);
        return util.exportExcel(critList, "审查记录");
    }
    
    /**
     * @Title: certificateDetail
     * @Description: 证书详情
     * @Author wtj
     * @DateTime 2020-9-25 17:12:05
     * @param guid
     * @param mmap
     * @return
     */
    @RequiresPermissions("completion:reviewRecord:cert")
    @GetMapping("/certificateDetail/{guid}")
    public String certificateDetail(@PathVariable("guid") String guid,ModelMap mmap)
    {
    	BaseCompletionRecordCertInfo bcrci = baseCompletionRecordCertInfoService.selectCompletionRecordCertInfoByGuid(guid);
    	mmap.put("bcrci", bcrci);
    	return prefix + "/certificateDetail";
    }
}
